const { API_VC_HOST } = require('./config')
const axios = require('axios')
const router = require('koa-router')()

// 获取抽奖详情
router.get('/getDetail', async (ctx, next) => {
  // https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id=576482837032351242
  const url = `${API_VC_HOST}/dynamic_svr/v1/dynamic_svr/get_dynamic_detail`
  const res = await axios.get(url, {
    params: ctx.request.query
  })
  ctx.response.body = res.data
  await next()
})

// 获取奖品信息
router.get('/getPrize', async (ctx, next) => {
    // https://api.vc.bilibili.com/lottery_svr/v1/lottery_svr/lottery_notice?business_type=4&business_id=576482837032351242
  const url = `${API_VC_HOST}/lottery_svr/v1/lottery_svr/lottery_notice`
  const res = await axios.get(url, {
    params: ctx.request.query
  })
  ctx.response.body = res.data
  await next()
})

module.exports = router
